package com.sgb.kjwl.view.widget;

import android.content.Context;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.View;
import android.widget.TextView;

import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.GoodsSkuDetailEntity;
import com.sgb.kjwl.view.ui.adapter.material.GoodsSkuAdapter;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;

public class GoodSAttributeWindow extends BasePopWindow {
    private RecyclerView paramsList;
    private TextView tv_close;
    private GoodsSkuAdapter goodsSkuAdapter;
    private LinearLayoutManager linearLayoutManager;


    public GoodSAttributeWindow(Context context) {
        super(context, DIR_DOWN_UP);
    }

    @Override
    protected int popLayout() {
        return R.layout.pop_goods_attribute;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        paramsList = holder.getPop().findViewById(R.id.params_list);
        tv_close = holder.getPop().findViewById(R.id.tv_close);
        if (goodsSkuAdapter == null) {
            goodsSkuAdapter = new GoodsSkuAdapter(mContext, null);
        }
        linearLayoutManager = new LinearLayoutManager(mContext);
        paramsList.setLayoutManager(linearLayoutManager);
        paramsList.setAdapter(goodsSkuAdapter);
        tv_close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    public void setData(GoodsSkuDetailEntity data) {
        if (data != null && data.getItemAttr() != null)
            goodsSkuAdapter.setDatas(data.getItemAttr().getSku());
    }
}
